<?php 

if($session->is_logged_in()) { // if user all ready logged inn send the user to the index of the admin area.
  redirect_to("/../../../public/view/admin/index.php");
}
  $sloginusername = "";
  $sloginpassword = "";
  $errorusernamepassword ="";
  $brukerikkeaktivert ="";
  $message = "";
if (isset($_POST['slogin'])) { // the Form from userlogin has been submitted.

// Sets the variables from the post of the the form    
  $sloginusername = trim($_POST['sloginusername']);
  $sloginpassword = trim($_POST['sloginpassword']);

 $message = $user_controller->authUser($sloginusername,$sloginpassword);
      

}

 // This form uses ulogin.php in includes/controller/form/ here all data is beeing processed.
           ?>

    
    <?php
        if($message != "" && empty($message)){
            echo "<div id='error'>";
            echo $message +"</div>"; 
    }?> 
<form id="ulogin" method="post" action="#" >
     

      <label> Epost</label> <input type="email" name="sloginusername" size="25" required="required" minlength="2" placeholder="Skriv epost" value="<?php echo htmlentities($sloginusername);?>" /><br />
       
        <p>
       <br/>
       <label> Passord </label> <input type="password" name="sloginpassword" size="25" required="required" minlength="6" placeholder="Skriv passord" value="<?php echo htmlentities($sloginpassword); ?>"  placeholder="Trykk passord"/>
       </p>
       
        <p>
 <input type="submit" name="slogin" value="Logg inn" /> 
        </p>
 </form>